package com.asset.salesforce.validator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import org.springframework.beans.factory.annotation.Autowired;

import com.asset.salesforce.service.CompanyService;


public class CompanyCheckerConstraintValidator implements ConstraintValidator<CompanyChecker, Object> {

	@Autowired
	CompanyService companyService;

	@Override
	public void initialize(CompanyChecker arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean isValid(Object target, ConstraintValidatorContext arg1) {
		if(companyService.getCompanyByName((String) target) != null){
			return true;
		}else{
			return false;
		}
	}


}
	 